var city="沧州";
var zhi=document.querySelector("#zhi").innerHTML="沧州";
function loadXMLDoc()
{
    var xmlhttp;
    if (window.XMLHttpRequest)
    {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            var json=JSON.parse(xmlhttp.responseText);
            console.log(json);
            document.querySelector("#b").innerHTML=json.now.tmp;
            document.querySelector("#span3").innerHTML=json.daily_forecast[0].tmp.min;
            document.querySelector("#span4").innerHTML=json.daily_forecast[0].tmp.max;
            document.querySelector("#p1").innerHTML=json.now.cond.txt;
            document.querySelector("#p2").innerHTML=json.now.wind.dir;
            document.querySelector("#p3").innerHTML=json.aqi.city.qlty;
            document.querySelector("#p4").innerHTML=json.suggestion.uv.brf;
            document.querySelector("#a1").innerHTML=json.suggestion.uv.txt;
            document.querySelector("#p5").innerHTML=json.suggestion.sport.brf;
            document.querySelector("#a2").innerHTML=json.suggestion.sport.txt;
            document.querySelector("#p6").innerHTML=json.suggestion.drsg.brf;
            document.querySelector("#a3").innerHTML=json.suggestion.drsg.txt;
            document.querySelector("#p7").innerHTML=json.suggestion.cw.brf;
            document.querySelector("#a4").innerHTML=json.suggestion.cw.txt;
            document.querySelector("#p8").innerHTML=json.suggestion.air.brf;
            document.querySelector("#a5").innerHTML=json.suggestion.air.txt;
            document.querySelector("#f1").innerHTML=json.hourly_forecast[0].date;
            document.querySelector("#f2").innerHTML=json.hourly_forecast[0].cond.txt;
            document.querySelector("#f3").innerHTML=json.hourly_forecast[0].tmp;
            document.querySelector("#f4").innerHTML=json.hourly_forecast[0].wind.dir;
            document.querySelector("#w1").innerHTML=json.daily_forecast[0].date;
            document.querySelector("#w2").innerHTML=json.daily_forecast[1].date;
            document.querySelector("#w3").innerHTML=json.daily_forecast[2].date;
            document.querySelector("#w4").innerHTML=json.daily_forecast[3].date;
            document.querySelector("#w5").innerHTML=json.daily_forecast[4].date;
            document.querySelector("#w6").innerHTML=json.daily_forecast[5].date;
            document.querySelector("#f5").innerHTML=json.hourly_forecast[1].date;
            document.querySelector("#f6").innerHTML=json.hourly_forecast[1].cond.txt;
            document.querySelector("#f7").innerHTML=json.hourly_forecast[1].tmp;
            document.querySelector("#f8").innerHTML=json.hourly_forecast[1].wind.dir;
            document.querySelector("#f9").innerHTML=json.hourly_forecast[2].date;
            document.querySelector("#f10").innerHTML=json.hourly_forecast[2].cond.txt;
            document.querySelector("#f11").innerHTML=json.hourly_forecast[2].tmp;
            document.querySelector("#f12").innerHTML=json.hourly_forecast[2].wind.dir;
            document.querySelector("#f13").innerHTML=json.hourly_forecast[3].date;
            document.querySelector("#f14").innerHTML=json.hourly_forecast[3].cond.txt;
            document.querySelector("#f15").innerHTML=json.hourly_forecast[3].tmp;
            document.querySelector("#f16").innerHTML=json.hourly_forecast[3].wind.dir;
            document.querySelector("#f17").innerHTML=json.hourly_forecast[4].date;
            document.querySelector("#f18").innerHTML=json.hourly_forecast[4].cond.txt;
            document.querySelector("#f19").innerHTML=json.hourly_forecast[4].tmp;
            document.querySelector("#f20").innerHTML=json.hourly_forecast[4].wind.dir;
            document.querySelector("#f21").innerHTML=json.hourly_forecast[5].date;
            document.querySelector("#f22").innerHTML=json.hourly_forecast[5].cond.txt;
            document.querySelector("#f23").innerHTML=json.hourly_forecast[5].tmp;
            document.querySelector("#f24").innerHTML=json.hourly_forecast[5].wind.dir;
            document.querySelector("#f25").innerHTML=json.hourly_forecast[6].date;
            document.querySelector("#f26").innerHTML=json.hourly_forecast[6].cond.txt;
            document.querySelector("#f27").innerHTML=json.hourly_forecast[6].tmp;
            document.querySelector("#f28").innerHTML=json.hourly_forecast[6].wind.dir;
            document.querySelector("#f29").innerHTML=json.hourly_forecast[7].date;
            document.querySelector("#f30").innerHTML=json.hourly_forecast[7].cond.txt;
            document.querySelector("#f31").innerHTML=json.hourly_forecast[7].tmp;
            document.querySelector("#f32").innerHTML=json.hourly_forecast[7].wind.dir;
            document.querySelector("#spanq").innerHTML=json.daily_forecast[1].tmp.min;
            document.querySelector("#spanw").innerHTML=json.daily_forecast[1].tmp.max;
            document.querySelector("#spanq1").innerHTML=json.daily_forecast[2].tmp.min;
            document.querySelector("#spanw2").innerHTML=json.daily_forecast[2].tmp.max;
            document.querySelector("#spanq3").innerHTML=json.daily_forecast[3].tmp.min;
            document.querySelector("#spanw4").innerHTML=json.daily_forecast[3].tmp.max;
            document.querySelector("#spanq5").innerHTML=json.daily_forecast[4].tmp.min;
            document.querySelector("#spanw6").innerHTML=json.daily_forecast[4].tmp.max;
            document.querySelector("#spanq7").innerHTML=json.daily_forecast[5].tmp.min;
            document.querySelector("#spanw8").innerHTML=json.daily_forecast[5].tmp.max;
            document.querySelector("#q1").innerHTML=json.daily_forecast[1].cond.txt_d;
            document.querySelector("#q2").innerHTML=json.daily_forecast[1].wind.dir;
            document.querySelector("#q3").innerHTML=json.daily_forecast[2].cond.txt_d;
            document.querySelector("#q4").innerHTML=json.daily_forecast[2].wind.dir;
            document.querySelector("#q5").innerHTML=json.daily_forecast[3].cond.txt_d;
            document.querySelector("#q6").innerHTML=json.daily_forecast[3].wind.dir;
            document.querySelector("#q7").innerHTML=json.daily_forecast[4].cond.txt_d;
            document.querySelector("#q8").innerHTML=json.daily_forecast[4].wind.dir;
            document.querySelector("#q9").innerHTML=json.daily_forecast[5].cond.txt_d;
            document.querySelector("#q10").innerHTML=json.daily_forecast[5].wind.dir;

        }
    };
    xmlhttp.open("GET","https://bird.ioliu.cn/weather?city="+city,true);
    xmlhttp.send();
}
loadXMLDoc();

document.querySelector("#ipt").addEventListener('change',function(){
    city=this.value;
    document.querySelector("#zhi").innerHTML=this.value;
    loadXMLDoc();
});



